Skip to content

Conversation

valentinewallace
Copy link
Contributor

Some cleanups in preparation for implementing sending payments as an often-offline sender to an often-offline recipient.

cc #2298

This method was rustfmt'd in the previous commit, here we clean up that
formatting.
This method will be edited in upcoming commits, and the codebase policy is to
at least consider removing rustfmt::skips when touching a method.
This method will be edited in upcoming commits, and the codebase policy is to
at least consider removing rustfmt::skips when touching a method.
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Sep 2, 2025

👋 Thanks for assigning @joostjager as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

Copy link

codecov bot commented Sep 2, 2025

Codecov Report

❌ Patch coverage is 93.51852% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.79%. Comparing base (5b6b691) to head (11f3476).
⚠️ Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/outbound_payment.rs 91.01% 8 Missing ⚠️
lightning/src/ln/channelmanager.rs 94.44% 5 Missing ⚠️
lightning-dns-resolver/src/lib.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4044      +/-   ##
==========================================
+ Coverage   88.73%   88.79%   +0.06%     
==========================================
  Files         176      176              
  Lines      129042   129310     +268     
  Branches   129042   129310     +268     
==========================================
+ Hits       114501   114824     +323     
+ Misses      11939    11891      -48     
+ Partials     2602     2595       -7     
Flag Coverage Δ
fuzzing 22.04% <27.01%> (+0.12%) ⬆️
tests 88.63% <93.51%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@valentinewallace valentinewallace force-pushed the 2025-09-async-send-prefactor branch 4 times, most recently from dfbf3ae to 408001c Compare September 2, 2025 21:22
});

if let PendingHTLCRouting::Forward { short_channel_id, .. } = payment.forward_info.routing {
let htlc_source = HTLCSource::PreviousHopData(payment.htlc_previous_hop_data());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phantom secret was set to None always, where as now it's taken from forward_info. No problem? Also at the last change in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should always be None here I believe regardless, since intercept payments and phantom payments both lean on special scids I don't think it would be possible to have a payment be both intercept and phantom.

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

$secp_ctx,
&Scalar::from_be_bytes(hop_pk_blinding_factor).unwrap(),
)?
pk.mul_tweak($secp_ctx, &Scalar::from_be_bytes(hop_pk_blinding_factor).unwrap())
Copy link
Contributor

@joostjager joostjager Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what the original reason was for making an exception here and not panicking for blinded paths specifically? Is there any way in which input causing this could be provided from the outside?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't believe so, I wrote the code originally and I think it just made the code look better and there was no reason not to handle the error at the time.

In upcoming commits, we will be adding several more conversions from
PendingAddHTLCInfo into HTLCPreviousHopData. This conversion gets repeated all
over the ChannelManager already, so lay some groundwork by DRYing it up.
Without this DRYing, we would be repeating the same code to instantiate the
PendingAddHTLCInfo several more times in this method, in upcoming commits.
The LDK codebase in general is comfortable panicking if the entropy source
provided to it is dysfunctional. Up until now we made an exception for blinded
path creation, where we would handle an error that could occur on mul_tweak
that could only occur if the session_priv provided was not actually random.
In comparable cases in onion_utils, we would panic instead.

In upcoming commits, we will be including blinded paths in outbound
revoke_and_ack messages as part of implementing async payments, where it is
difficult to handle failing back an HTLC if blinded path creation fails. Thus
we now have an incentive to make the blinded path creation methods infallible,
so do so here.
Copy link
Contributor

@elnosh elnosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started looking at subsequent PRs for async sending, prefactor here LGTM

Copy link
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I would say it's good to ask a second reviewer. It's more than strict refactoring, some reasoning about why things are equivalent is needed.

@ldk-reviews-bot
Copy link

✅ Added second reviewer: @tankyleo

@joostjager
Copy link
Contributor

Apologies @elnosh, I missed your LGTM.

@valentinewallace valentinewallace added the weekly goal Someone wants to land this this week label Sep 4, 2025
@valentinewallace valentinewallace self-assigned this Sep 4, 2025
htlc_id: prev_htlc_id,
incoming_packet_shared_secret: forward_info
.incoming_shared_secret,
phantom_shared_secret: None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joost mentioned this above @valentinewallace can you confirm we can set this to Some in the PendingHTLCRouting::Receive case ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline, this part is unreachable in the PendingHTLCRouting::Receive case. In that case, scid == 0 and fake_scid::is_valid_intercept called before this line will return false for any scid equal to 0.

@valentinewallace valentinewallace merged commit 654180d into lightningdevkit:main Sep 4, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
weekly goal Someone wants to land this this week
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants